//-----------------------------------------------------------------------
// <copyright file="OfficeService.cs" company="Pyramid Consulting">
//     Copyright (c) Pyramid Consulting. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------	

using System;
using System.Collections;
using MyFramework;
using MIMS.WRS.Entities;
using MIMS.WRS.Data;
    
namespace MIMS.WRS.Business
{   
	/// <summary>
	/// 
	/// </summary> 
    public class OfficeService
    {
        #region Office

        public static void CreateOffice(Office office)
        {            
            try
            {
                OfficeDAO officeDAO = new OfficeDAO();
                officeDAO.CreateOffice(office);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessCreateOfficeException, ex);
            }
        }        

        public static void UpdateOffice(Office office)
        {            
            try
            {
                OfficeDAO officeDAO = new OfficeDAO();
                officeDAO.UpdateOffice(office);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessUpdateOfficeException, ex);
            }
        }        

        public static void DeleteOffice(int officeID)
        {            
            try
            {
                OfficeDAO officeDAO = new OfficeDAO();
                officeDAO.DeleteOffice(officeID);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessDeleteOfficeException, ex);
            }
        }
        
        public static Office GetOffice(int officeID)
        {            
            try
            {
                OfficeDAO officeDAO = new OfficeDAO();
                return officeDAO.GetOffice(officeID);                
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetOfficeException, ex);
            }
        }                

        public static OfficeCollection GetOffices(OfficeColumns orderBy, OrderDirection orderDirection)
        {            
            try
            {
                OfficeDAO officeDAO = new OfficeDAO();
                return officeDAO.GetOffices(orderBy, orderDirection);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetOfficesException, ex);
            }
        }        

        public static OfficeCollection GetOffices(OfficeColumns orderBy, OrderDirection orderDirection, int page, int pageSize, out int totalRecords)
        {            
            try
            {
                OfficeDAO officeDAO = new OfficeDAO();
                return officeDAO.GetOffices(orderBy, orderDirection, page, pageSize, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetOfficesException, ex);
            }
        }        

        #endregion

		public static OfficeCollection GetOffices(int userID)
		{            
			try
			{
				OfficeDAO officeDAO = new OfficeDAO();
				return officeDAO.GetOffices(userID);
			}
			catch (BusinessException)
			{
				throw;
			}
			catch (Exception ex)
			{
				// log this exception
				Logger.Error(ex);
				// wrap it and rethrow
				throw new BusinessException(SR.BusinessGetOfficesException, ex);
			}
		}       
    }
}